package experimentReport.servlet;

import jakarta.servlet.http.*;

import java.io.*;
import java.util.regex.*;

public class SevenTwo extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws IOException {
        Pattern pt = Pattern.compile("-?[0-9]+(\\.[0-9]+)?");
        Matcher mt = pt.matcher(req.getParameter("numbers"));
        String[] number = {"取整后除3余0:", "取整后除3余1:", "取整后除3余2:"};
        while (mt.find()) {
            int num = (int) Double.parseDouble(mt.group());
            if (num % 3 == 0) num = 0;
            else if (num % 3 == 1) num = 1;
            else num = 2;
            number[num] += mt.group() + " ";
        }
        resp.setContentType("text/html;charset=utf-8");
        resp.getWriter().write(number[0] + "<br>" + number[1] + "<br>" + number[2]);
    }
}
